package com.toolbox.json

import com.toolbox.utils.DateUtil
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider


class CustomDateTimeByLong extends JsonSerializer<Long> {

    @Override
    void serialize(Long value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
        //转换的格式为  yyyy-MM-dd HH:mm:ss
        jgen.writeString(DateUtil.formatTime(value,null));
    }
}
